Let's say we want to prepare data and try some scalers and classifiers for prediction in a classification problem. We will tune paramaters of classifiers by grid search technique.
Data preparing:
In [1]:
from sklearn.datasets import make_classification
X, y = make_classification()
data = {'X': X, 'y': y}
Setting steps for our pipelines and parameters for grid search:
In [2]:
from reskit.core import Pipeliner
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import MinMaxScaler
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
classifiers = [('LR', LogisticRegression()),
('SVC', SVC())]
scalers = [('standard', StandardScaler()),
('minmax', MinMaxScaler())]
steps = [('scaler', scalers),
('classifier', classifiers)]
param_grid = {'LR': {'penalty': ['l1', 'l2']},
'SVC': {'kernel': ['linear', 'poly', 'rbf', 'sigmoid']}}
Creating a plan of our research:
In [3]:
pipe = Pipeliner(steps, param_grid=param_grid)
pipe.plan_table
Out[3]:
To tune parameters of models and evaluate this models, run:
In [4]:
pipe.get_results(data=data, scoring=['roc_auc'])
Out[4]: